import request from '@/utils/request'

// 查询分页库区 + 查询(精确查询)
export const getLocationPage = (pageConfig, searchQuery) => {
  const params = { ...pageConfig }
  if (searchQuery) {
    const [areaName, name, status] = searchQuery
    if (name) params.name = name
    if (areaName) params.areaName = areaName
    if (status !== '') params.status = status
  }
  return request.get('/location/pageDetail', { params })
}

// 删除库区
export const delLocation = (id) => request.delete('location', { params: { ids: [id] }})

// 新增库区时获取库区编码
export const getLocationCode = () => request.get('/codeFactory/next/KW')

// 查询库区类型
// export const getLocationType = () => request.get('/goodsType/list')

// 查询货主
// export const getOwnerList = () => request.get('/owner/list')

// 查询库区 /area/list
// export const getWarehouseArea = (id) => request.get(`/area/list?ownerId=${id}`)

// 查询仓库列表
export const getWarehouse = () => request.get('/warehouse/list?status=1')

// 新增库区
export const addLocation = (data) => request.post('/location', data)

// 根据id查询库区详情
export const getLocationDetails = (id) => request.get(`/location/${id}`)

// 编辑库区
export const editLocation = (data) => request.put('/location', data)
